
* Set directories
cd /Users/byrned/Dropbox/Research/InformedSources/Replication/Analysis/
local datdir /Users/byrned/Dropbox/Research/InformedSources/Replication/Build/Output/


*- Figure 3: Retail Pricing with Coles On and Off the Informed Sources Platform -*

* Load data
use `datdir'is_mel_p_2005_2019, clear

* Dates for xlabels
local x1=td(1jul2015)
local x2=td(1jan2016)
local x3=td(1jul2016)
local x4=td(1jan2017)
local x5=td(1jul2017)
local x6=td(1jan2018)
local x7=td(1jul2018)

* Compute mean price by market, brand, date
sort bid t
collapse (mean) p c, by(bid t)

* Sample Period
keep if t>=td(1may2015) & t<=td(31dec2017)

* Highlighting window where Coles starts losing access
gen yoff1=90
gen yoff2=150
gen y1=145
gen y2=145
gen x1=td(1jun2016)+3
gen x2=td(1may2016)+3
local xtext1=td(30sep2016)
twoway 	(rarea yoff1 yoff2 t if bid==1 & t>=td(1apr2016) & t<td(1may2016), vertical color(grey*0.20%30)) ///
		(line p t if bid==1, lwidth(thin)   connect(stairstep) lcolor(gs0*0.85)  lpattern(dash)) ///
		(line p t if bid==2, lwidth(thin)   connect(stairstep) lcolor(gs0*0.7)   lpattern(shortdash) ) ///
		(line p t if bid==3, lwidth(medthick) connect(stairstep) lcolor(gs0)  lpattern(solid) ) ///
		(line p t if bid==4, lwidth(thin)   connect(stairstep) lcolor(gs0*0.55) lpattern(dash_dot)) ///
		(line p t if bid==5, lwidth(thin)   connect(stairstep) lcolor(gs0*0.4) lpattern(longdash)) ///
		(line c t if bid==1, lwidth(medthick) connect(stairstep) lcolor(gs0) lpattern(shortdash)  ///		
		ytitle("Mean Station-Level Retail Price (cpl)", height(6)) ylabel(90(10)170, labsize(*0.8) grid) ///
		xtitle("Date", height(6)) ///
		xlabel(`x1' `" "Jul 1"  "2015" "' `x2' `" "Jan 1"  "2016" "' `x3' `" "Jul 1"  "2016" "' `x4' `" "Jan 1"  "2017" "' ///
			   `x5' `" "Jul 1"  "2017" "' `x6' `" "Jan 1"  "2018" "', labsize(*0.7)) ///
		plotregion(margin(zero) style(none)) ///
		legend(order(2 3 4 5 6 7) ring(0) size(*0.75) position(11) symx(*0.5) symy(*0.5) region(lwidth(*0.05)) rows(1) ///
		label(2 "BP") label(3 "Caltex") label(4 "Coles") label(5 "Woolworths") label(6 "7-Eleven") label(7 "Wholesale" "TGP")) ///
		text(145 `xtext1' "Coles Informed Sources" "contract expires", justification(left) size(*0.7))) ///
		(pcarrow y1 x1 y2 x2, color(black) lwidth(*1) barbsize(1) msize(2))
graph export Output/fig3_prices.pdf, as(pdf) replace


